import React from 'react';
 import { Row, Col, Calendar, Badge} from 'antd';
 import moment from 'moment';
import 'moment/locale/zh-cn';
moment.locale('zh-cn');

class Home extends React.Component {


    render() {

        function dateCellRender(value) {
            const today = new Date();
            const thisMonth =   today.getMonth() ;

            const listData = getListData(value ,thisMonth+1);
            return (
                <ul className="events">
                    {listData.map(item => (
                        <li key={item.type}>
                            <Badge status={item.type} />
                        </li>
                    ))}
                </ul>
            );
        }


        function getListData(time_,thisMonth_) {
            let listData =[];
            const thisMonth =time_.month();
            if((thisMonth+1) != thisMonth_){
                return listData;
            }
            const month_01 = new Array(2,4,7,12,15,18,20,21,22,23,25) ;
            const month_02 = new Array(2,7,9,14,16,19,23,27,30) ;
            const month_03 = new Array(2,4,7,12,15,18,20,21,22,23,25) ;
            const month_04 = new Array(2,7,9,14,16,19,23,27,30) ;
            const month_05 = new Array(2,7,9,14,16,19,23,27,30) ;

            const month_06 = new Array(2,4,7,12,15,18,20,25,22,23,25) ;
            const month_07 = new Array(2,7,9,14,16,19,23,27,30) ;

            const month_08 = new Array(3,6,10,12,18,20,25,27) ;
            const month_09 = new Array(6,7,11,13,14,17,18,21,24,25,28,30) ;
            const month_10 = new Array(2,4,7,12,15,18,20,21,22,23,25) ;
            const month_11 = new Array(2,4,7,12,15,18,20,21,22,23,25) ;
            const month_12 = new Array(2,4,7,12,15,18,20,21,22,23,25) ;

            const  list = new Array(month_01,month_02,month_03,month_04,
                    month_05,month_06,month_07,month_08,
                    month_09,month_10,month_11,month_12)  ;

            const m = list[thisMonth] ;
            for(let j = 0,len= m.length; j < len; j++) {
                if(time_.date() == m[j]){
                    listData = [
                        { type: 'success'},
                    ];
                }
            }
        return listData;
        }




        return (
            <div>
                <Row >
                    <Col xs={24} sm={24} md={6} lg={6} xl={6}>
                    </Col>
                    <Col xs={24} sm={24} md={12} lg={12} xl={12}  >
                        <br/><br/>
                            <Calendar fullscreen={false}   dateCellRender={dateCellRender}  />
                    </Col>
                    <Col xs={24} sm={24} md={6} lg={6} xl={6}>
                    </Col>
                </Row>
            </div>
        );
    }
}



export default Home;